package com.cdl;

import java.util.Scanner;

/**
 * @author cdl
 * @date 2025/9/30
 */
public class Retirement {
    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);

        System.out.println("How much money do you need to retire? ");
        double goal = scanner.nextDouble(); //目标

        System.out.println("How much money will you contribute every year?");
        double payment = scanner.nextDouble(); //支付

        System.out.println("Interest rate in %: ");
        double interestRate = scanner.nextDouble(); //利率

        double balance = 0;
        int years =0;

        while (balance < goal){

            balance += payment;
            double interest = balance * interestRate /100; //利息
            balance +=interest;
            years++;

        }

        System.out.println("You can retire in " + years + " years.");




    }
}
